package com.imooc.pan.stream.core;

import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;

import javax.swing.plaf.metal.MetalBorders;
import java.util.Objects;

/**
 * 消费者的共用父类
 * 主要做公用逻辑的抽离
 */

@Slf4j
public abstract class AbstractConsumer {
    protected void printLog(Message message) {
        log.info("{} start consume the message, the message is {}", this.getClass().getSimpleName(), message);
    }

    /**
     * 校验传入的消息
     *
     * @return
     */

    protected boolean isEmptyMessage(Message message) {
        if (Objects.isNull(message)) {
            return true;
        }
        Object payload = message.getPayload();
        if (Objects.isNull(payload)) {
            return true;
        }
        return false;
    }
}
